local keys = cmsgpack.unpack(ARGV[1]);
local values = cmsgpack.unpack(ARGV[2]);
local keysSize = table.getn(keys);
for i=1,keysSize do
  local tmpKey = keys[i];
  local tmpValue = values[i];
  redis.call("HSET",KEYS[1],tmpKey,tmpValue);
end
local listCndKey = KEYS[2].."_CONDITION_LIST~key";
local listCnd = redis.call("ZRANGE",listCndKey,0,-1);
if (listCnd~=nil) then
  local listCndSize = table.getn(listCnd);
  for i=1,listCndSize do
    local cndkey = listCnd[i];
    local cndkey_sub = string.gsub(cndkey, KEYS[2].."_CONDITION_LIST_", "");
    cndkey_sub = string.gsub(cndkey_sub, "~key", "");
    if(assert(loadstring(cndkey_sub))()) then
      redis.call("ZADD",cndkey,0,KEYS[1]);
    end
  end
end